﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using QLChoDiaOc.Process;

namespace QLChoDiaOc.Forms
{
    /// <summary>
    /// Interaction logic for WinToBao.xaml
    /// </summary>
    public partial class WinToBao : Window
    {
        GetID _getID = new GetID();
        InsertInfo _insertInfo = new InsertInfo();
        public WinToBao()
        {
            InitializeComponent();
            AddComboBoxThuPhatHanh();
            maToBaoWinTextBox.Text = _getID.GenerateMaToBao();
        }

        void AddComboBoxThuPhatHanh()
        {
            for (int i = 2; i <= 7; i++)
                thuPhatHanhWinComboBox.Items.Add("Thứ " + i.ToString());
            thuPhatHanhWinComboBox.Items.Add("Chủ nhật");
        }

        private void btnThemLoaiDiaOcWin_Click(object sender, RoutedEventArgs e)
        {
            if (tenToBaoWinTextBox.Text == "" || donGiaToBaoWinTextBox.Text == "" || thuPhatHanhWinComboBox.SelectedItem == null)
                MessageBox.Show("Bạn chưa nhập đầy đủ thông tin", "Thông Báo");
            else
            {
                try
                {
                    _insertInfo.InsertToBao(maToBaoWinTextBox.Text, tenToBaoWinTextBox.Text, thuPhatHanhWinComboBox.SelectedItem.ToString(), int.Parse(donGiaToBaoWinTextBox.Text));
                    btnThemToBaoWin.IsEnabled = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Thông Báo");
                }
            }
        }

        private void btnThoatLoaiDiaOcWin_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
